//
//  JWSideViewController.m
//  见闻新闻
//
//  Created by brother on 16/3/14.
//  Copyright © 2016年 JoanBoat. All rights reserved.
//

#import "JWSideViewController.h"

#import "JWSideView.h"

#import "JWLoginViewController.h"

#import "JWShowMeViewController.h"

#import "AppDelegate.h"

#import "JWUpUserDataTools.h"

#import <MBProgressHUD.h>

@interface JWSideViewController ()
@property(nonatomic,copy)NSString *row;
@end

@implementation JWSideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     
     [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(presentLogin) name:@"headBtnClick" object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(TableViewCellClick:) name:@"TableViewCellClick" object:nil];
    
   
    // Do any additional setup after loading the view.
}

-(void)TableViewCellClick:(NSNotification *)MyClickindexPath{
    
    self.row = MyClickindexPath.userInfo[@"A"];
//    NSLog(@"%@",self.row);
    
    if ([self.row isEqualToString:@"0"]) {
        UIViewController *VC = [[UIViewController alloc]init];
        VC.view.backgroundColor = [UIColor grayColor];
        [self presentViewController:VC animated:YES completion:nil];
    }

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    
  
    //设置冰川背景图
    UIImageView *img=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sidebar_bg.jpg"]];
    
    CGSize  tempSize = [[UIScreen mainScreen] bounds].size;
    
    img.frame=CGRectMake(0,0,tempSize.width,tempSize.height*0.4);
    [self.view addSubview:img];
    
    
    
    JWSideView *sideVW = [[JWSideView alloc] initWithFrame:CGRectMake(0, 0,MyScreenSize.width,MyScreenSize.height)];
    
    [self.view addSubview:sideVW];
    
    [JWUpUserDataTools updataToUserAvatar:sideVW.headImage HUDView:sideVW];
    
   }



-(void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = YES;

}


-(void)presentLogin {
    
    UIStoryboard *homeStoryboard = [UIStoryboard storyboardWithName:@"Home" bundle:nil];
    
    
    JWLoginViewController *LoginVC = [homeStoryboard instantiateViewControllerWithIdentifier:@"Login"];

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];

    
    if (appDelegate.isLogin == NO ) {
        
    [self  presentViewController:LoginVC animated:YES completion:nil];

    }else if (appDelegate.isLogin == YES){
        
        JWShowMeViewController * showMeVC = [[JWShowMeViewController alloc] initWithNibName:@"JWShowMeViewController" bundle:nil];

        [self  presentViewController:showMeVC animated:YES completion:nil];
        
        
    }
    
  }


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
